package com.jeremyfeinstein.socket;


import android.util.Log;

import com.jeremyfeinstein.utils.ConfigUtil;

/**
 * Created by sunxunchao on 2019/2/18.
 */
public class SocketFactory {

    private static final String TAG = "SocketFactory";

    private static SimpleSocketClient ychsSocket;
    private static SimpleSocketClient ychsRemoteSocket;

    public static SimpleSocketClient newYCHSSocket(){
        synchronized (SocketFactory.class){
            if (ychsSocket == null){
                String url = ConfigUtil.getInstance().getLocalSocketUrl();
                Log.d(TAG, "newYCHSSocket: url ===> " + url);
                ychsSocket = new YCHSSocketClient(url);
            }
        }
        return ychsSocket;
    }

    public static SimpleSocketClient newYCHSRemoteSocket(){
        synchronized (SocketFactory.class){
            if (ychsRemoteSocket == null){
                String url = ConfigUtil.getInstance().getRemoteSocketUrl();
                Log.d(TAG, "newYCHSRemoteSocket: url ===> " + url);
                ychsRemoteSocket = new YCHSSocketClient(url);
            }
        }
        return ychsRemoteSocket;
    }
}
